﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Serialization;
using System.Xml.Xsl;

namespace HelloXslt
{
    class Program
    {
        static void Main(string[] args)
        {
            XslCompiledTransform xsl = new XslCompiledTransform();
            xsl.Load("cdcatalog.xsl");
            var sb = new StringBuilder();
            using (var sw = new StringWriter(sb))
            {
                using (var xw = new XmlTextWriter(sw) { Formatting = Formatting.Indented })
                {
                    xsl.Transform("cdcatalog.xml", xw);
                }
            }

            var xml = sb.ToString();
            Console.WriteLine(xml);
            var xmlSerializer = new XmlSerializer(typeof(List<string>));
            using (var ms = new MemoryStream(Encoding.UTF8.GetBytes(xml)))
            {
                var list = (List<string>) xmlSerializer.Deserialize(ms);
                foreach (var item in list)
                {
                    Console.WriteLine(item);
                }
            }
        }
    }
}
